#include "MenuItem.h"
#include <cassert>
#include <iostream>
#include <string>

using namespace std;

MenuItem::MenuItem(string name, BITMAP* graphic, int xPos, int yPos, void(*callback)(void)) {
    assert(callback != NULL);
    assert(graphic != NULL);
    assert(xPos > -1);
    assert(yPos > -1);    
    mItemName = name;
    mGraphic = graphic;
    mXpos = xPos;
    mYpos = yPos;

    /* These are not set by what is passed as parameters to ctor */
    mWidth = 100;
    mHeight = 50;

    /* setting callback-function */
    mCallback = callback;
   
}

MenuItem::MenuItem(const MenuItem& orig) {
}

MenuItem::~MenuItem() {
}

void MenuItem::execute() {
    mCallback();
}

BITMAP* MenuItem::getBitmap() {
    assert(mGraphic != NULL);
    return mGraphic;
}

string MenuItem::getText(){
    return mItemName;
}

int MenuItem::getXPos() {
    return mXpos;
}

int MenuItem::getYPos() {
    return mYpos;
}

bool MenuItem::posIsOnItem(int xPos, int yPos) {
    if(xPos >= mXpos && xPos <= (mXpos+mWidth) &&
            yPos >= mYpos && yPos <= (mYpos+mHeight)) {
        return true;
    }
    else
        return false;
}

